from django.test import TestCase

# Create your tests here.
from aliyunsdkcore.client import AcsClient
from aliyunsdkcore.request import CommonRequest
import random

def send_alysms(phone,sms_code):
    AK = "LTAI4FdhTDbCRthWWB7bMSw3"
    SK = "c3Tix3XTQkJoshEcIoUoO8EnlHk4UW"

    client = AcsClient(AK, SK, 'cn-hangzhou')

    request = CommonRequest()
    request.set_accept_format('json')
    request.set_domain('dysmsapi.aliyuncs.com')
    request.set_method('POST')
    request.set_protocol_type('https') # https | http
    request.set_version('2017-05-25')
    request.set_action_name('SendSms')

    request.add_query_param('RegionId', "cn-hangzhou")
    request.add_query_param('PhoneNumbers', "18843833387")  # 自己现在用的手机号
    request.add_query_param('SignName', "图图")   # 短信签名的库名
    request.add_query_param('TemplateCode', "SMS_185555433")  # 这是短信模板的code
    request.add_query_param('TemplateParam', "{\"code\":123654}")


    response = client.do_action(request)
    # python2:  print(response)
    print(str(response, encoding = 'utf-8'))


def get1():
    # phone = request.data.get("phone","")
    code = random.randint(100000,999999)
    print(code)

get1()